package com.cauli.manage.storage.model.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cauli.manage.storage.model.entity.Storage;
import com.cauli.model.dto.BaseQueryDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Cauli
 * @date 2023-03-28 12:00
 * @description 存储源添加参数
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "StorageQueryDTO", description = "存储源查询参数")
public class StorageQueryDTO extends BaseQueryDTO {
    @ApiModelProperty("存储源状态（0正常 1停用）")
    private Integer status;

    @Override
    public LambdaQueryWrapper<Storage> toLambdaQueryWrapper() {
        LambdaQueryWrapper<Storage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(status != null, Storage::getStatus, status)
                .eq(Storage::getDeleted, 0);
        return lambdaQueryWrapper;
    }
}
